package com.dgt.trade.service.impl;

import com.dgt.trade.dao.TradeDao;
import com.dgt.trade.entitys.trade.Data;
import com.dgt.trade.entitys.trade.Product;
import com.dgt.trade.entitys.trade.Products;
import com.dgt.trade.service.TradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class TradeServiceImpl implements TradeService {

	@Autowired
	private TradeDao tradeDao;

	@Override
	public HashMap<String,Object> getKByCodeAndType(String code, Integer type) {
        HashMap<String,Object> res=new HashMap<String,Object>();

        String data_content=tradeDao.getKByCodeAndType(code,type);
        res.put("data",data_content);
//	    if(type>0){
//            HashMap<String,Object> maData=tradeDao.getMaByCodeAndType(code);
//            res.putAll(maData);
//        }
		return res;
	}

	@Override
	public List<Product> getProducts(){
		return tradeDao.getProducts();
	}

	@Override
	public HashMap<String, Object> getFreshData(String code) {
		return tradeDao.getFreshDataByCodeAndType(code);
	}

	@Override
	public HashMap<String,Object> getFsData(String code) {
		HashMap<String,Object> res=new HashMap<String,Object>();
		List<Data> data=tradeDao.getFsDataByCode(code);
		res.put("data",data);
		return res;
	}

	@Override
	public HashMap<String, Object> getProductsOrderBy(HashMap<String, Object> map) {
		return tradeDao.getProductsOrderBy(map);
	}

	@Override
	public int updatePriceByCode(String code, String last_price, String change_count) {
		return tradeDao.updatePriceByCode(code,last_price,change_count);
	}

	@Override
	public 	int updateDataByCode(String code,String last_price,String high,String low,String open,String close,String volume,String amount,String bv,String sv,String bp,String sp,String change_count){
		return tradeDao.updateDataByCode(code,last_price,high,low,open,close,volume,amount,bv,sv,bp,sp,change_count);
	}

}
